package com.atguigu.patterns.singleton;


//饿汉式(静态代码块)
public class SingletonStaticCodeBlock implements AbstractSingleton {
	
	//1. 构造器私有化, 外部能new
	private SingletonStaticCodeBlock(){}

	//2.本类内部创建对象实例
	private  static SingletonStaticCodeBlock instance;
	
	static { // 在静态代码块中，创建单例对象
		instance = new SingletonStaticCodeBlock();
	}
	
	//3. 提供一个公有的静态方法，返回实例对象
	public static SingletonStaticCodeBlock getInstance() {
		return instance;
	}
	
}
